package com.ala4.oxcafe.boot.utils;

import jakarta.servlet.http.HttpServletResponse;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

/**
 * 请求上下文工具类
 *
 * @author PING
 * @version 1.0.0
 * @date 2025/8/1 14:49
 */
public class ResponseUtil {

    private ResponseUtil() {
    }

    public static HttpServletResponse getResponse() {
        ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
        if (attributes != null) {
            return attributes.getResponse();
        }
        throw new IllegalStateException("当前线程未绑定请求上下文");
    }

}
